import requests

from common.get_headers_util import get_headers
from common.get_id_util import get_id


class IhrmEmploeeApi:

    #员工添加
    @classmethod
    def ihrm_emploee_insert_api(cls,json_data):
        emp_insert_resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                                        headers=get_headers(),
                                        json=json_data)
        return emp_insert_resp

    #员工修改
    @classmethod
    def ihrm_emploee_put_api(cls,json_data):
        update_resp = requests.put(url=f"http://ihrm2-test.itheima.net/api/sys/user/{get_id()}",
                                   headers=get_headers(),
                                   json=json_data)
        return update_resp
    #员工删除
    @classmethod
    def ihrm_emploee_delete_api(cls):
        delete_resp=requests.delete(url=f"http://ihrm2-test.itheima.net/api/sys/user/{get_id()}",
                                    headers=get_headers())
        return delete_resp

    #员工查询
    @classmethod
    def ihrm_emploee_select_api(cls):
        select_resp=requests.get(url=f"http://ihrm2-test.itheima.net/api/sys/user/{get_id()}",
                                 headers=get_headers())
        return select_resp


if __name__ == '__main__':
    print(IhrmEmploeeApi.ihrm_emploee_put_api({"username": "lily"}).json())